Skip to content

Conversation

ohno418
Copy link
Contributor

@ohno418 ohno418 commented Apr 29, 2024

When encountering code like:

#[cfg(key = ["a", "b"])]
fn main() {}

the parser incorrectly suggests:

error: expected unsuffixed literal, found `[`
 --> ../pg/src/main.rs:1:13
  |
1 | #[cfg(key = ["foo", "bar"])]
  |             ^
  |
help: surround the identifier with quotation marks to parse it as a string
  |
1 | #[cfg(key =" "["foo", "bar"])]
  |            + +

error: aborting due to 1 previous error

This commit modifies the parser to check if an attribute value is an ident before suggesting.

@rustbot
Copy link
Collaborator

rustbot commented Apr 29, 2024

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 29, 2024
@ohno418
Copy link
Contributor Author

ohno418 commented Apr 29, 2024

r? diagnostics

@rustbot rustbot assigned TaKO8Ki and unassigned nnethercote Apr 29, 2024
@compiler-errors
Copy link
Member

This needs a test

@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 29, 2024
@compiler-errors compiler-errors self-assigned this Apr 29, 2024
@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 29, 2024
@ohno418 ohno418 force-pushed the improve-suggesting-attr-val branch from ef15235 to ea04951 Compare May 2, 2024 08:02
When encountering code like:

```
#[cfg(key = ["foo", "bar"])]
fn main() {}
```

the parser incorrectly suggests:

```
error: expected unsuffixed literal, found `[`
 --> ../pg/src/main.rs:1:13
  |
1 | #[cfg(key = ["foo", "bar"])]
  |             ^
  |
help: surround the identifier with quotation marks to parse it as a string
  |
1 | #[cfg(key =" "["foo", "bar"])]
  |            + +

error: aborting due to 1 previous error
```

This commit modifies the parser to check if an attribute value is an
ident before suggesting.
@ohno418
Copy link
Contributor Author

ohno418 commented May 2, 2024

Added a test.

@compiler-errors
Could you take another look at this?
r? @compiler-errors

@rustbot
Copy link
Collaborator

rustbot commented May 2, 2024

Could not assign reviewer from: compiler-errors.
User(s) compiler-errors are either the PR author, already assigned, or on vacation, and there are no other candidates.
Use r? to specify someone else to assign.

@bors
Copy link
Collaborator

bors commented May 10, 2024

☔ The latest upstream changes (presumably #124972) made this pull request unmergeable. Please resolve the merge conflicts.

@ohno418
Copy link
Contributor Author

ohno418 commented Jun 8, 2024

Closing as this has been fixed by 0ad3c5d.

@ohno418 ohno418 closed this Jun 8, 2024
@ohno418 ohno418 deleted the improve-suggesting-attr-val branch June 8, 2024 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants